# coding=utf-8

# 字符串的合并
a = 'agag'
b = 'sgag'

c = a + b
print(c)  # agagsgag

# 字符串的检索
str_data = 'hello world'

print(str_data.find('l'))  # 2
print(str_data.index('w'))  # 6
print(str_data.startswith('h'))  # True
print(str_data.startswith('a'))  # False
print(str_data.endswith('d'))  # True
print(str_data.endswith('a'))  # False
print(str_data[2:4])  # ll

# 字符串的更新
update_str = 'woshinibaba'
print(update_str.replace('b', 'B'))  # woshiniBaBa
print(update_str.split('b'))  # ['woshini', 'a', 'a']
print('*'.join(update_str.split('i')))  # wosh*n*baba

# 字符串删除

delete_str = ' [ksakjghaga] '
print(delete_str.strip())  # [ksakjghaga]
print(delete_str.strip().strip('[]'))  # ksakjghaga

# 字符串格式化输出

str_content = '我叫{}，今年{}岁'.format('陈烨', '18')
print(str_content)  # 我叫陈烨，今年18岁

str_content1 = '{0},{1},{2},{3},{2}'.format('beng', 'xia', 'ka', 'la')
print(str_content1)  # beng,xia,ka,la,ka

str_content2 = '我叫{name}, 今年{age}岁'.format(name='陈烨', age=18)
print(str_content2)  # 我叫陈烨, 今年18岁

city = '上海'
print(f'{city}-东方明珠')  # 上海-东方明珠


